package yxy.game.pm2.module.tip.checker;

import yxy.game.pm2.bean.module.rank.IWorshipableRank;
import yxy.game.pm2.bean.module.rank.RankEntry;
import yxy.game.pm2.bean.module.rank.RankWorshipPlayer;
import yxy.game.pm2.module.active.progress.RankProgressArea;
import yxy.game.pm2.module.active.progress.RankProgressPerson;
import yxy.game.pm2.module.arena.RankArena;
import yxy.game.pm2.module.conquest.RankConquest;
import yxy.game.pm2.module.player.RankPlayerPower;
import yxy.game.pm2.module.tip.TipHandle;
import yxy.game.pm2.module.tip.TipType;
import yxy.game.pm2.module.tower.RankTower;

public class Checker_排行榜 {
	public void check(String playerCode) {
		check(playerCode, RankPlayerPower.getRank(playerCode), TipType.征战_排行榜按钮_战力_膜拜);
		check(playerCode, RankConquest.getRank(playerCode), TipType.征战_排行榜按钮_征战_膜拜);
		check(playerCode, RankTower.getRank(playerCode), TipType.征战_排行榜按钮_修炼塔_膜拜);
		check(playerCode, RankArena.getRank(playerCode), TipType.征战_排行榜按钮_竞技场_膜拜);
		
		RankProgressPerson.get(playerCode, RankProgressArea.ConquestRank);
		RankProgressPerson.get(playerCode, RankProgressArea.TowerRank);
		RankProgressPerson.get(playerCode, RankProgressArea.PowerRank);
	}

	public void check(String playerCode, IWorshipableRank rank, TipType tipType) {
		new TipHandle().updateTip(playerCode, tipType, check(playerCode, rank));
	}

	public boolean check(String playerCode, IWorshipableRank rank) {
		
		RankWorshipPlayer rankWorshipPlayer = RankWorshipPlayer.get(playerCode, rank.getWorship());
		if (rankWorshipPlayer.remainTimes() <= 0) {
			return false;// 没有膜拜次数了
		}
		RankEntry entry = rank.entryByRanking(1);
		if (entry == null) {
			return false;// 膜拜的名次没有人
		}
		String code = entry.getKey();
		if (code.equals(playerCode)) {
			return false;// 不能膜拜自己
		}
		if (rankWorshipPlayer.getWorshiped().contains(code)) {
			return false;// 已经膜拜过了
		}

		return true;
	}
}
